package com.zkthink.ceres.tenant.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableId;
import com.zkthink.base.entity.Entity;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import static com.zkthink.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;
import com.zkthink.ceres.tenant.enumeration.TenantTypeEnum;
import com.zkthink.ceres.tenant.enumeration.TenantStatusEnum;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;

/**
 * <p>
 * 实体类
 * 商家表
 * </p>
 *
 * @author kellen
 * @since 2020-05-05
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("d_tenant")
@ApiModel(value = "Tenant", description = "商家表")
@AllArgsConstructor
public class Tenant extends Entity<Long> {

    private static final long serialVersionUID = 1L;

    /**
     * 企业编码
     */
    @ApiModelProperty(value = "企业编码")
    @Length(max = 20, message = "企业编码长度不能超过20")
    @TableField(value = "code", condition = LIKE)
    @Excel(name = "企业编码")
    private String code;

    /**
     * 企业名称
     */
    @ApiModelProperty(value = "企业名称")
    @Length(max = 255, message = "企业名称长度不能超过255")
    @TableField(value = "name", condition = LIKE)
    @Excel(name = "企业名称")
    private String name;

    /**
     * 类型
     * #{CREATE:创建;REGISTER:注册}
     */
    @ApiModelProperty(value = "类型")
    @TableField("type")
    @Excel(name = "类型", replace = {"创建_CREATE", "注册_REGISTER",  "_null"})
    private TenantTypeEnum type;

    /**
     * 状态
     * #{NORMAL:正常;FORBIDDEN:禁用;WAITING:待审核;REFUSE:拒绝}
     */
    @ApiModelProperty(value = "状态")
    @TableField("status")
    @Excel(name = "状态", replace = {"正常_NORMAL", "禁用_FORBIDDEN", "待审核_WAITING", "拒绝_REFUSE",  "_null"})
    private TenantStatusEnum status;

    /**
     * 是否内置
     */
    @ApiModelProperty(value = "是否内置")
    @TableField("readonly")
    @Excel(name = "是否内置", replace = {"是_true", "否_false", "_null"})
    private Boolean readonly;

    /**
     * 责任人
     */
    @ApiModelProperty(value = "责任人")
    @Length(max = 50, message = "责任人长度不能超过50")
    @TableField(value = "duty", condition = LIKE)
    @Excel(name = "责任人")
    private String duty;

    /**
     * 地址
     */
    @ApiModelProperty(value = "地址")
    @Length(max = 500, message = "地址长度不能超过500")
    @TableField(value = "address", condition = LIKE)
    @Excel(name = "地址")
    private String address;

    /**
     * 生效时限
     */
    @ApiModelProperty(value = "生效时限，单位年")
    @TableField("expire_limit_year")
    @Excel(name = "生效时限")
    private Integer expireLimitYear;

    /**
     * 生效时间
     */
    @ApiModelProperty(value = "生效时间")
    @TableField("start_time")
    @Excel(name = "生效时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime startTime;

    /**
     * 失效时间
     */
    @ApiModelProperty(value = "失效时间")
    @TableField("expiration_time")
    @Excel(name = "失效时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime expirationTime;

    /**
     * 联系电话
     */
    @ApiModelProperty(value = "联系电话")
    @Length(max = 16, message = "联系电话长度不能超过16")
    @TableField(value = "contact_tel", condition = LIKE)
    @Excel(name = "联系电话")
    private String contactTel;

    /**
     * logo地址
     */
    @ApiModelProperty(value = "logo地址")
    @Length(max = 255, message = "logo地址长度不能超过255")
    @TableField(value = "logo", condition = LIKE)
    @Excel(name = "logo地址")
    private String logo;

    /**
     * 企业简介
     */
    @ApiModelProperty(value = "企业简介")
    @Length(max = 255, message = "企业简介长度不能超过255")
    @TableField(value = "describe_", condition = LIKE)
    @Excel(name = "企业简介")
    private String describe;

    @ApiModelProperty("商家对应的登录账号")
    @TableField(exist = false)
    private String account;

    @Builder
    public Tenant(Long id, LocalDateTime createTime, Long createUser, LocalDateTime updateTime, Long updateUser,
        String code, String name, TenantTypeEnum type, TenantStatusEnum status, Boolean readonly,
        String duty, String address, Integer expireLimitYear, LocalDateTime startTime, LocalDateTime expirationTime, String contactTel,
        String logo, String describe) {
        this.id = id;
        this.createTime = createTime;
        this.createUser = createUser;
        this.updateTime = updateTime;
        this.updateUser = updateUser;
        this.code = code;
        this.name = name;
        this.type = type;
        this.status = status;
        this.readonly = readonly;
        this.duty = duty;
        this.address = address;
        this.expireLimitYear = expireLimitYear;
        this.startTime = startTime;
        this.expirationTime = expirationTime;
        this.contactTel = contactTel;
        this.logo = logo;
        this.describe = describe;
    }

}
